package org.ushio.nchu_22201408.controller;

import org.ushio.common_module.entity.CustomerServiceRecord;
import org.ushio.common_module.entity.RepairRecord;
import org.ushio.common_module.entity.RepairmanRating;
import org.ushio.nchu_22201408.Feign.ServiceOnlineRecordClient;
import org.ushio.nchu_22201408.mapper.RepairmanRatingMapper;
import org.ushio.nchu_22201408.service.RepairmanRatingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/repairman-ratings")
public class RepairmanRatingController {

    private final RepairmanRatingService repairmanRatingService;
    private final ServiceOnlineRecordClient serviceOnlineRecordClient;
    @Autowired
    public RepairmanRatingController(RepairmanRatingService repairmanRatingService,ServiceOnlineRecordClient serviceOnlineRecordClient) {
        this.repairmanRatingService = repairmanRatingService;
        this.serviceOnlineRecordClient = serviceOnlineRecordClient;
    }

    @PostMapping("insertRepairRatingController")
    public String createRepairmanRating(@RequestBody RepairmanRating rating) {
        repairmanRatingService.createRating(rating);
        return "Repairman rating created successfully";
    }
    @GetMapping("/maintain-records")
    public List<RepairRecord> getMaintainRecordsByPhoneNumber(@RequestParam String phoneNumber) {
        List<RepairRecord> result = serviceOnlineRecordClient.getMaintainGetByPhoneNumber(phoneNumber);
        return result;
    }
}